﻿ 
//-------------页面初始化--------------
function initPage()
{
	initDataCtrl();
	onClickQuery_TotalUserCount();
	initCalendar();
} 

var calendarName;
function initCalendar() 
{ 
	calendarName=new Calendar("div_calendar", "calendarName");
	calendarName.init();
	
	window.onresize=function () { 
			calendarName.setDivPos();  //可以调整日历的相对位置
	}
}
	
//
function initDataCtrl()
{
	var myDate=new Date()
	
	tmpYear = myDate.getFullYear();
	tmpMonth = myDate.getMonth()+1;
	tmpDate = myDate.getDate();
	
	if(tmpMonth <= 9)
		tmpMonth = "0" + tmpMonth;
	if(tmpDate <= 9)
		tmpDate = "0" + tmpDate;
	
	strYearMonth = tmpYear + "-" + tmpMonth;
	strDateTime =  strYearMonth + "-" + tmpDate;
	
	$("year_month").value = strYearMonth;
	$("datetime_begin").value = strDateTime;
	$("datetime_end").value = strDateTime;
	
	$("year_month").onclick = YearMonthOnclick;
	$("datetime_begin").onclick = DateBeginOnclick;
	$("datetime_end").onclick = DateEndOnclick;
	
	$("attribute_datetime_begin").value = strDateTime;
	$("attribute_datetime_end").value = strDateTime;
	
	$("attribute_datetime_begin").onclick = DateBeginOnclick2;
	$("attribute_datetime_end").onclick = DateEndOnclick2;
}

//-------------查询---用户总数--------
function onClickQuery_TotalUserCount()
{		
	var data = "";
	PostToPHP(__onClickQuery_TotalUserCountCallback, "sys_log", "total_query_user_count", data);
}
function __onClickQuery_TotalUserCountCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);
	var ds = GetDataSet(jsonObj);
	if(ds && ds[0])
	{
        var items = ds[0];
		for(var name in items)
		{ 
			tmpObj = $(name);   
			if(tmpObj)
			{	
				tmpObj.value = items[name];
			}
		}
	}
} 

//-------------查询---月登陆--------
function onClickQuery_TotalUserCountLoginMonth()
{		
	var data = "year_month=" + $("year_month").value; 
	PostToPHP(__onClickQuery_TotalUserCountLoginMonthCallback, "sys_log", "total_query_user_count_login_month", data);
}
function __onClickQuery_TotalUserCountLoginMonthCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);
	var ds = GetDataSet(jsonObj);
	if(ds && ds[0])
	{
        var items = ds[0];
		for(var name in items)
		{ 
			tmpObj = $(name);   
			if(tmpObj)
			{	
				tmpObj.value = items[name];
			}
		}
	}
}  

//-------------查询基本数据记录-----------
function onClickQuery_basic()
{ 	
	CleanConfig(); //清空配置  
			  
	AddItemConfig("datetime", 0);  				//日期
	AddItemConfig("day_login", 0);  			//日登录
	AddItemConfig("day_login_distinct", 0);  	//日登录(去重复)
	AddItemConfig("day_reg", 0);  				//日新增注册
	AddItemConfig("day_online_heigh", 0);  		//日最高在线
	AddItemConfig("day_online_low", 0);  		//日最低在线
	AddItemConfig("day_online_average", 0);  	//日平均在线  
	
	AddItemConfig("day_login_sumtime", 0);  	//日在线总时长
	AddItemConfig("day_login_sumtime_avg", 0);  //日平均在线时长
	
	var _data_1 = "&datetime_begin=" + $("datetime_begin").value 
		_data_1 += "&datetime_end=" + $("datetime_end").value;
	//alert(_data_1);
	bDirectQueryData = true; //直接查询数据, 不查询总数
	SetPagingConfig("paging_sys_log", null, _data_1, 
					"paging_sys_log", "get_sys_log_basic_list", _data_1, bDirectQueryData);
	PagingInit(1, "tbody_query", "div_paging");            
}


//-------------查询属性数据-----------
function onClickQuery_attribute()
{
	CleanConfig(); //清空配置  
			  
	AddItemConfig("datetime", 0);  				//日期	
	AddItemConfig("day_gold_sys_provide", 0);  	//日发放金币数
	AddItemConfig("day_gold_use", 0);  			//日消耗金币数
	AddItemConfig("day_money_sys_provide", 0);  //日充值比索数
	AddItemConfig("day_money_use", 0);  		//日消耗比索数
	
	var _data_1 = "&datetime_begin=" + $("attribute_datetime_begin").value 
		_data_1 += "&datetime_end=" + $("attribute_datetime_end").value;
	//alert(_data_1);
	bDirectQueryData = true; //直接查询数据, 不查询总数
	SetPagingConfig("paging_sys_log", null, _data_1, 
					"paging_sys_log", "get_sys_log_basic_attribute_list", _data_1, bDirectQueryData);
	PagingInit(1, "attribute_tbody_query", "attribute_div_paging");  
}


function YearMonthOnclick()
{
	calendarName.show('year_month', '', true);
}

function DateBeginOnclick()
{
	calendarName.show('datetime_begin', '');
}

function DateEndOnclick()
{
	calendarName.show('datetime_end', '');
}

function DateBeginOnclick2()
{
	calendarName.show('attribute_datetime_begin', '');
}

function DateEndOnclick2()
{
	calendarName.show('attribute_datetime_end', '');
}
